package com.jihox.abookpro.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Page implements Serializable{
	
	//内页
	public static final int REGULAR = 1;
	//竖版照片封面
	public static final int PORTRAIT_FRONT_COVER = 2;
	//横版照片封面
	public static final int LANDSCAPE_FRONT_COVER = 3;
	//方形照片封面
	public static final int SQUARE_FRONT_COVER = 4;
	//默认封面
	public static final int UNDEFINED_FRONT_COVER = 5;
	//封底
	public static final int BACK_COVER = 6;
	
	public static final int SPINE_NUMBER = 1005;
	public final static int FRONT_COVER_NUMBER = 0;
	public final static int BACK_COVER_NUMBER = 1000;
	
	private int type = REGULAR;
	private int number =0;
	private String background="";
	private int backgroundRemovable = 0;
	private List<PagePicture> pictures;
	private List<Caption> captions;
	private boolean isHollow = false;
	private boolean isJigsaw = false;
	private float height = 0;
	private int componentType = 1;
	public boolean editingAllowed =true;
	public boolean layoutLocked = false;
	private boolean needRedraw = true;
	
	public boolean isNeedRedraw() {
		return needRedraw;
	}

	public void setNeedRedraw(boolean needRedraw) {
		this.needRedraw = needRedraw;
	}

	public int getComponentType() {
		return componentType;
	}
	
	public void setComponentType(){
		componentType = (FRONT_COVER_NUMBER < number && BACK_COVER_NUMBER > number) ? 2 :1;
	}

	public float getHeight() {
		return height;
	}

	public void setHeight(float height) {
		this.height = height;
	}

	public float getWidth() {
		return width;
	}

	public void setWidth(float width) {
		this.width = width;
	}

	private float width = 0;
	
	public Page() {
		pictures = new ArrayList<PagePicture>();
		captions = new ArrayList<Caption>();
	}
	
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public int getNumber() {
		return number;
	}
	public void setNumber(int number) {
		this.number = number;
	}
	public String getBackground() {
		return background;
	}
	public void setBackground(String background) {
		this.background = background;
	}
	public List<PagePicture> getPictures() {
		return pictures;
	}
	public void setPictures(List<PagePicture> pictures) {
		this.pictures = pictures;
	}
	public List<Caption> getCaptions() {
		return captions;
	}
	public void setCaptions(List<Caption> captions) {
		this.captions = captions;
	}
	public boolean isHollow() {
		return isHollow;
	}
	public void setHollow(boolean isHollow) {
		this.isHollow = isHollow;
	}
	public boolean isJigsaw() {
		return isJigsaw;
	}
	public void setJigsaw(boolean isJigsaw) {
		this.isJigsaw = isJigsaw;
	}
	
	public boolean isCover() {
		return (type == PORTRAIT_FRONT_COVER || type == LANDSCAPE_FRONT_COVER || type == SQUARE_FRONT_COVER || type == UNDEFINED_FRONT_COVER || type == BACK_COVER);
	}

	public static boolean isCover(int pageNum) {
		return pageNum == Page.FRONT_COVER_NUMBER || pageNum == Page.BACK_COVER_NUMBER;
	}

	public static boolean isFrontCover(int pageNum) {
		return pageNum == Page.FRONT_COVER_NUMBER ;
	}

	public boolean isBackCover() {
		return number == Page.BACK_COVER_NUMBER ;
	}
	
	public boolean isSpine() {
		return number == Page.SPINE_NUMBER;
	}
}
